<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@taglib uri="http://www.springframework.org/tags" prefix="spring"%>
<%@taglib uri="http://www.springframework.org/tags/form" prefix="form"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	<title>Page MOA</title>
	
  	<link rel="stylesheet" href="<c:url value="/resources/Styles/styles.css"/>"/>
	<script src="<c:url value="/resources/js/jquery-1.8.3.js"/>"></script>

  	<script>

	function validerMoa(id){

		var statut = $('#statut_'+id).val();

		if(confirm("Etes-vous sur de vouloir modifier cette application?")){
		
			$.ajax({
				type: "POST",
				url: "<c:url value="modifier"/>",
				data: "id=" + id+"&statut=" + statut,
				success: function(response){
					// we have the response
					if(response == "success"){
						alert("Application modifiée avec succés ...");
					}else{
						alert("Aucune modification apportée!");
					}
	
					window.location.href = "<c:url value="/moa/showApps"/>";
				},
				error: function(e){
					
				}
			});
		}
	}
	
</script>
  	
</head>
<body>

<form:form method="post" action="modifierTout" commandName="ApplicationMOAForm" id="form">

<div align="center"><h3><spring:message code="index.listeApps"/></h3></div>

<table id="tableView" align="center" border="1" width="1000">

	<tr>
		<td colspan="6" align="right"><form:button>Valider la modification</form:button></td>
	</tr>
	<tr>
		<th width="20%">Logo</th>
		<th width="25%">Libelle</th>
		<th width="25%">Lien</th>
		<th width="10%">Etat</th>
		<th width="10%">Montant</th>
		<th width="10%">Actions</th>
	</tr>

	<c:forEach items="${listApplication}" var="application">
	<tr >

		<td>
			<a onclick="javascript:todo();">
				<img src= "<c:url value="/resources/img/participations/${application.image}" />" title="rechercher"/>
			</a>
		</td>

		<td>${application.libelle}</td>
		<td>${application.lien}</td>

   		<td width="10%">
			<form:select path="mapStatuts[${application.id}] " id="statut_${application.id}">
			   <form:option value="0" label="--- Select ---"/>
			   <form:options items="${listeStatut}" />
			</form:select>			
		</td>
		
		<td>${application.montant}</td>

		<td>
			<a onclick="javascript:validerMoa(${application.id})">
				<img src="<c:url value="/resources/img/valider.png"/>" title="valider">
			</a>
		</td>
	
	</tr>
	</c:forEach>

</table>

</form:form>
</body>
</html>